<template>
  <div>
    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
    >
      <el-menu-item index="1" style="font-size:24px;">员工绩效配置</el-menu-item>
      <el-menu-item index="2" style="font-size:24px;">组织部门绩效配置</el-menu-item>
    </el-menu>
    <div class="more-btns">
      <el-button v-if="yuangongFlag==true" type="primary" @click="updateData">编辑</el-button>
      <el-button v-if="yuangongFlag==false" type="primary" @click="saveData">保存</el-button>
      <el-button v-if="yuangongFlag==false" type="primary" @click="yuangongFlag=true,deptFlag=true,cancel()">取消</el-button>
    </div>
    <div class="performance_main_bottom">
      <table v-if="flag==1" width="85%" class="performance_main_bottom_table" style="margin: auto;">
        <tr>
          <td style="font-size:24px;">评估项</td>
          <td style="font-size:24px;">目标</td>
          <td style="font-size:24px;">分数配置</td>
          <td style="font-size:24px;">得分计算方法</td>
        </tr>
        <tr >
          <td>登录时长</td>
          <td>
                <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">一般用户</span>
                <el-input-number
                class="performance_main_bottom_input"
                :disabled="yuangongFlag"
                :formatter="rowtime1"
                v-model="row1.d1"
                controls-position="right"
                @change="handleChange"
                :min="1"
                ></el-input-number>
                <span>小时</span>
                <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">领导</span>
            <el-input-number
              class="performance_main_bottom_input"
              :formatter="rowtime2"
              :disabled="yuangongFlag"
              v-model="row1.d2"
              controls-position="right"
              @change="handleChange"
              :min="1"
            ></el-input-number>
            <span>小时</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">安全管理员</span>
            <el-input-number
              class="performance_main_bottom_input"
              :formatter="rowtime3"
              :disabled="yuangongFlag"
              v-model="row1.d3"
              controls-position="right"
              @change="handleChange"
              :min="1"
            ></el-input-number>
            <span>小时</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">系统管理员</span>
            <el-input-number
              class="performance_main_bottom_input"
              :formatter="rowtime4"
              :disabled="yuangongFlag"
              v-model="row1.d4"
              controls-position="right"
              @change="handleChange"
              :min="1"
            ></el-input-number>
            <span>小时</span>
          </td>
          <td>
            <el-input-number
              :formatter="rowtime1"
              :disabled="yuangongFlag"
              v-model="row1.d5"
              controls-position="right"
              @change="handleChange_row1d5(),yuangongChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
              {{row1.d6}}
          </td>
        </tr>
        <tr>
          <td>值班</td>
          <td>
              {{row2.d1}}
            <!-- <el-input class="performance_main_bottom_input" v-model="row2.d1" :disabled="true"></el-input> -->
          </td>
          <td>
            <el-input-number
              v-model="row2.d2"
              :disabled="yuangongFlag"
              controls-position="right"
              @change="handleChange(),yuangongChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">早退或迟到一次，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              v-model="row2.d3"
              :disabled="yuangongFlag"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">缺卡一次，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row2.d4"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>应答</td>
          <td>
              {{row3.d1}}
          </td>
          <td>
            <el-input-number :disabled="yuangongFlag" @change="yuangongChange" v-model="row3.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每漏答1次,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row3.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>接警速度</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每次接警速度应低不超过</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row4.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分钟</span>
          </td>
          <td>
            <el-input-number :disabled="yuangongFlag" @change="yuangongChange" v-model="row4.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超时1次,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row4.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>警情复位速度</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">平均警情复位速度应低不超过</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row5.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>小时</span>
          </td>
          <td>
            <el-input-number :disabled="yuangongFlag" @change="yuangongChange" v-model="row5.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超过2小时,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row5.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>日常巡检完成度</td>
          <td>
              {{row6.d1}}
          </td>
          <td>
            <el-input-number :disabled="yuangongFlag" @change="yuangongChange" v-model="row6.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每遗漏1个点位,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row6.d3"
              controls-position="right"
              :min="0.5"
              :step="0.5"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>隐患创建</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">月度创建数量不低于</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row7.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number :disabled="yuangongFlag" @change="yuangongChange" v-model="row7.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每缺1个,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row7.d3"
              controls-position="right"
              :min="0.5"
              :step="0.5"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>隐患及时整改</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">月度及时整改完成数量不低于</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="yuangongFlag"
              v-model="row8.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number
            :disabled="yuangongFlag"
              v-model="row8.d2"
              controls-position="right"
              @change="handleChange(),yuangongChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每少整改1个，扣</span>
            <el-input-number
            :disabled="yuangongFlag"
              class="performance_main_bottom_input"
              v-model="row8.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超时整改1个，扣</span>
            <el-input-number
            :disabled="yuangongFlag"
              class="performance_main_bottom_input"
              v-model="row8.d4"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>学习时长</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">月度及时整改完成数量不低于</span>
            <el-input-number
            :disabled="yuangongFlag"
              class="performance_main_bottom_input"
              v-model="row9.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number
            :disabled="yuangongFlag"
              v-model="row9.d2"
              controls-position="right"
              @change="handleChange_row9d2(),yuangongChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
              {{row9.d3}}
          </td>
        </tr>
        <tr>
          <td>考试</td>
          <td>
              {{row10.d1}}
          </td>
          <td>
            <el-input-number
            :disabled="yuangongFlag"
              v-model="row10.d2"
              controls-position="right"
              @change="handleChange_row10d2(),yuangongChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
              {{row10.d3}}
          </td>
        </tr>
      </table>
      <div v-if="flag==1  && yuangongFlag==false"><span>汇总</span><span>【{{rowallGrade}}】</span></div>
      <!-- 组织部门绩效配置 -->
      <table v-if="flag==2" width="85%" class="performance_main_bottom_table" style="margin: auto;">
        <tr>
          <td style="font-size:24px;">评估项</td>
          <td style="font-size:24px;">目标</td>
          <td style="font-size:24px;">分数配置</td>
          <td style="font-size:24px;">得分计算方法</td>
        </tr>
        <tr>
          <td>登录时长</td>
          <td>
              {{deptRow1.d1}}
            <!-- <el-input v-model="deptRow1.d1" controls-position="right"></el-input> -->
          </td>
          <td>
            <el-input-number
              :disabled="deptFlag"
              v-model="deptRow1.d2"
              controls-position="right"
              @change="departmentChange_deptRow1d2,deptChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
            {{deptRow1.d3}}
          </td>
        </tr>
        <tr>
          <td>值班</td>
          <td>
            {{deptRow2.d1}}
          </td>
          <td>
            <el-input-number :disabled="deptFlag" @change="deptChange" v-model="deptRow2.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">早退或迟到一次，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow2.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">缺卡一次，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow2.d4"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>应答</td>
          <td>
            {{deptRow3.d1}}
          </td>
          <td>
            <el-input-number :disabled="deptFlag" @change="deptChange" v-model="deptRow3.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每漏答1次,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow3.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>接警速度</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每次接警速度应低不超过</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow4.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分钟</span>
          </td>
          <td>
            <el-input-number :disabled="deptFlag"  @change="deptChange" v-model="deptRow4.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超时1次,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow4.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>警情复位速度</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">平均警情复位速度应低不超过</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow5.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>小时</span>
          </td>
          <td>
            <el-input-number :disabled="deptFlag"  @change="deptChange" v-model="deptRow5.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超过2小时,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow5.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>日常巡检完成度</td>
          <td>
            {{deptRow6.d1}}
          </td>
          <td>
            <el-input-number :disabled="deptFlag"  @change="deptChange" v-model="deptRow6.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每遗漏1个点位,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow6.d3"
              controls-position="right"
              :min="0.5"
              :step="0.5"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>隐患创建</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">平均每人月度创建数量不低于</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow7.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number :disabled="deptFlag"  @change="deptChange" v-model="deptRow7.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每缺1个,扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow7.d3"
              controls-position="right"
              :min="0.5"
              :step="0.5"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>隐患及时整改</td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">平均每人月度及时整改完成数量不低于</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow8.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number :disabled="deptFlag"  @change="deptChange" v-model="deptRow8.d2" controls-position="right" :min="1"></el-input-number>
            <span>分</span>
          </td>
          <td>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每少整改1个，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow8.d3"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
            <div class="line"></div>
            <span style="display:block;width:300px;float:left;margin-top:10px;text-align: right;">每超时整改1个，扣</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow8.d4"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
        </tr>
        <tr>
          <td>学习时长</td>
          <td>
            <span cstyle="display:block;width:300px;float:left;margin-top:10px;text-align: right;">平均每人月度学习时长不低于</span>
            <el-input-number
              class="performance_main_bottom_input"
              :disabled="deptFlag"
              v-model="deptRow9.d1"
              controls-position="right"
              :min="1"
            ></el-input-number>
            <span>个</span>
          </td>
          <td>
            <el-input-number
            :disabled="deptFlag"
              v-model="deptRow9.d2"
              controls-position="right"
              @change="departmentChange_deptRow9d2,deptChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
            {{deptRow9.d3}}
          </td>
        </tr>
        <tr>
          <td>考试</td>
          <td>
            {{deptRow10.d1}}
          </td>
          <td>
            <el-input-number
            :disabled="deptFlag"
              v-model="deptRow10.d2"
              controls-position="right"
              @change="departmentChange_deptRow10d2,deptChange()"
              :min="1"
            ></el-input-number>
            <span>分</span>
          </td>
          <td>
            {{deptRow10.d3}}
          </td>
        </tr>
      </table>
      <div style="margin-top:15px;font-size:20px;font-weight:blod" v-if="flag==2 && deptFlag==false"><span>汇总</span><span>【{{deptallGrade}}】</span></div>
    </div>
  </div>
</template>
<script>
import { getPerConfigInfo,updatePerInfo } from "@/api/rdLearnOrg";
export default {
  data() {
    return {
      activeIndex: "1",
      num: "1",
      flag: '1',
      workTable: [],
      edit: false,
      row1: {},
      row2: {},
      row3: {},
      row4: {},
      row5: {},
      row6: {},
      row7: {},
      row8: {},
      row9: {},
      row10: {},
      deptRow1: {},
      deptRow2: {},
      deptRow3: {},
      deptRow4: {},
      deptRow5: {},
      deptRow6: {},
      deptRow7: {},
      deptRow8: {},
      deptRow9: {},
      deptRow10: {},
      yuangongFlag:true,
      deptFlag:true,
      rowallGrade:0,//员工配置总分
      deptallGrade:0,//部门配置总分
    };
  },
  created() {
    let that = this;
    that.getPerConfigInfo();
  },
  methods: {
    handleSelect(key, keyPath) {
      let that = this;
      that.flag = keyPath;
      that.getPerConfigInfo();
    },
    //数据格式化
    rowtime1: function(row, column) {
      return JSON.parse(workTable[0].ruleSet)[0].time;
    },
    rowtime2: function(row, column) {
      return JSON.parse(workTable[0].ruleSet)[1].time;
    },
    rowtime3: function(row, column) {
      return JSON.parse(workTable[0].ruleSet)[2].time;
    },
    rowtime4: function(row, column) {
      return JSON.parse(workTable[0].ruleSet)[3].time;
    },
    // 获取员工/组织绩效规则表
    cancel(){
      let that = this;
      that.getPerConfigInfo();
    },
    getPerConfigInfo() {
      let that = this;
      let parames = {
        orgId: this.$store.state.userinfo.org.id,
        type: that.flag
        //bizId:'',暂时不传人大不需要，预留的
      };
      getPerConfigInfo(parames).then(res => {
        that.workTable = res.data;
        if (that.flag == 1) {
          that.handleRow1(that.workTable[0]);
          that.handleRow2(that.workTable[1]);
          that.handleRow3(that.workTable[2]);
          that.handleRow4(that.workTable[3]);
          that.handleRow5(that.workTable[4]);
          that.handleRow6(that.workTable[5]);
          that.handleRow7(that.workTable[6]);
          that.handleRow8(that.workTable[7]);
          that.handleRow9(that.workTable[8]);
          that.handleRow10(that.workTable[9]);
        } else {
          that.handleDeptRow1(that.workTable[0]);
          that.handleDeptRow2(that.workTable[1]);
          that.handleDeptRow3(that.workTable[2]);
          that.handleDeptRow4(that.workTable[3]);
          that.handleDeptRow5(that.workTable[4]);
          that.handleDeptRow6(that.workTable[5]);
          that.handleDeptRow7(that.workTable[6]);
          that.handleDeptRow8(that.workTable[7]);
          that.handleDeptRow9(that.workTable[8]);
          that.handleDeptRow10(that.workTable[9]);
        }
        that.rowallGrade = that.row1.d5+that.row2.d2+that.row3.d2+that.row4.d2+that.row5.d2+that.row6.d2+that.row7.d2+that.row8.d2+that.row9.d2+that.row10.d2
        that.deptallGrade = that.deptRow1.d2+that.deptRow2.d2+that.deptRow3.d2+that.deptRow4.d2+that.deptRow5.d2+that.deptRow6.d2+that.deptRow7.d2+that.deptRow8.d2+that.deptRow9.d2+that.deptRow10.d2
      });
    },
    handleChange() {
      //计算分数员工绩效
    },
    yuangongChange(){
      let that = this
      that.rowallGrade = that.row1.d5+that.row2.d2+that.row3.d2+that.row4.d2+that.row5.d2+that.row6.d2+that.row7.d2+that.row8.d2+that.row9.d2+that.row10.d2
      },
    deptChange(){
      let that = this
      that.deptallGrade = that.deptRow1.d2+that.deptRow2.d2+that.deptRow3.d2+that.deptRow4.d2+that.deptRow5.d2+that.deptRow6.d2+that.deptRow7.d2+that.deptRow8.d2+that.deptRow9.d2+that.deptRow10.d2
    },
    saveData(){//保存绩效
        let that =this;
        let ruleSet1 = {
            roleId:144,
            time:that.row1.d1
        }
        let ruleSet2 = {
            roleId:160,
            time:that.row1.d2
        }
        let ruleSet3 = {
            roleId:145,
            time:that.row1.d3
        }
        let ruleSet4 = {
            roleId:142,
            time:that.row1.d4
        }
        let ruleSet = [];
        ruleSet.push(ruleSet1,ruleSet2,ruleSet3,ruleSet4)
        let row0 = {
            perLibId:that.workTable[0].perLibId,
            ruleSet:JSON.stringify(ruleSet),
            totalPoints:that.row1.d5,
            arithmeticConfig:that.workTable[0].arithmeticConfig,
        }
        let arithmeticConfig1={
            $e1:that.row2.d3,
            $e2:that.row2.d4,
        }
        let row1 = {
            perLibId:that.workTable[1].perLibId,
            ruleSet:that.workTable[1].ruleSet,
            totalPoints:that.row2.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig1),
        }
        let arithmeticConfig2={
            $e1:that.row3.d3,
        }
        let row2 = {
            perLibId:that.workTable[2].perLibId,
            ruleSet:that.workTable[2].ruleSet,
            totalPoints:that.row3.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig2),
        }
        let arithmeticConfig3={
            $e1:that.row4.d3,
        }
        let row3 = {
            perLibId:that.workTable[3].perLibId,
            ruleSet:that.row4.d1,
            totalPoints:that.row4.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig3),
        }
        let arithmeticConfig4={
            $e1:that.row5.d3,
        }
        let row4 = {
            perLibId:that.workTable[4].perLibId,
            ruleSet:that.row5.d1,
            totalPoints:that.row5.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig4),
        }
        let arithmeticConfig5={
            $e1:that.row6.d3,
        }
        let row5 = {
            perLibId:that.workTable[5].perLibId,
            ruleSet:that.row6.d1,
            totalPoints:that.row6.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig5),
        }
        let arithmeticConfig6={
            $e1:that.row7.d3,
        }
        let row6 = {
            perLibId:that.workTable[6].perLibId,
            ruleSet:that.row7.d1,
            totalPoints:that.row7.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig6),
        }
        let arithmeticConfig7={
            $e1:that.row8.d3,
            $e2:that.row8.d4,
        }
        let row7 = {
            perLibId:that.workTable[7].perLibId,
            ruleSet:that.row8.d1,
            totalPoints:that.row8.d2,
            arithmeticConfig:JSON.stringify(arithmeticConfig7),
        }
        let row8 = {
            perLibId:that.workTable[8].perLibId,
            ruleSet:that.row9.d1,
            totalPoints:that.row9.d2,
            arithmeticConfig:that.workTable[8].arithmeticConfig,
        }
        let row9 = {
            perLibId:that.workTable[9].perLibId,
            ruleSet:that.workTable[9].ruleSet,
            totalPoints:that.row10.d2,
            arithmeticConfig:that.workTable[9].arithmeticConfig,
        }
        let bizConfigListStr = [];
        bizConfigListStr.push(row0,row1,row2,row3,row4,row5,row6,row7,row8,row9)
        //员工----------------------------------------------------------------------
            let dept0 = {
              perLibId:that.workTable[0].perLibId,
              ruleSet:that.workTable[0].ruleSet,
              totalPoints:that.deptRow1.d2,
              arithmeticConfig:that.workTable[0].arithmeticConfig,
            }
            let deptConfig2={
                $e1:that.deptRow2.d3,
                $e2:that.deptRow2.d4,
            }
            let dept1 = {
                perLibId:that.workTable[1].perLibId,
                ruleSet:that.workTable[1].ruleSet,
                totalPoints:that.deptRow2.d2,
                arithmeticConfig:JSON.stringify(deptConfig2),
            }
            let deptConfig3={
                $e1:that.deptRow3.d3,
            }
            let dept2 = {
                perLibId:that.workTable[2].perLibId,
                ruleSet:that.workTable[2].ruleSet,
                totalPoints:that.deptRow3.d2,
                arithmeticConfig:JSON.stringify(deptConfig3),
            }
            let deptConfig4={
                $e1:that.deptRow4.d3,
            }
            let dept3 = {
                perLibId:that.workTable[3].perLibId,
                ruleSet:that.deptRow4.d1,
                totalPoints:that.deptRow4.d2,
                arithmeticConfig:JSON.stringify(deptConfig4),
            }
            let deptConfig5={
                $e1:that.deptRow5.d3,
            }
            let dept4 = {
                perLibId:that.workTable[4].perLibId,
                ruleSet:that.deptRow5.d1,
                totalPoints:that.deptRow5.d2,
                arithmeticConfig:JSON.stringify(deptConfig5),
            }
            let deptConfig6={
                $e1:that.deptRow6.d3,
            }
            let dept5 = {
                perLibId:that.workTable[5].perLibId,
                ruleSet:that.workTable[5].ruleSet,
                totalPoints:that.deptRow6.d2,
                arithmeticConfig:JSON.stringify(deptConfig6),
            }
            let deptConfig7={
                $e1:that.deptRow7.d3,
            }
            let dept6 = {
                perLibId:that.workTable[6].perLibId,
                ruleSet:that.deptRow7.d1,
                totalPoints:that.deptRow7.d2,
                arithmeticConfig:JSON.stringify(deptConfig7),
            }
            let deptConfig8={
                $e1:that.deptRow8.d3,
                $e2:that.deptRow8.d4,
            }
            let dept7 = {
                perLibId:that.workTable[7].perLibId,
                ruleSet:that.deptRow8.d1,
                totalPoints:that.deptRow8.d2,
                arithmeticConfig:JSON.stringify(deptConfig8),
            }
            let dept8 = {
                perLibId:that.workTable[8].perLibId,
                ruleSet:that.deptRow9.d1,
                totalPoints:that.deptRow9.d2,
                arithmeticConfig:that.workTable[8].arithmeticConfig,
            }
            let dept9 = {
                perLibId:that.workTable[9].perLibId,
                ruleSet:that.workTable[9].ruleSet,
                totalPoints:that.deptRow10.d2,
                arithmeticConfig:that.workTable[9].arithmeticConfig,
            }
            let deptListStr = [];
            deptListStr.push(dept0,dept1,dept2,dept3,dept4,dept5,dept6,dept7,dept8,dept9)
        //组织----------------------------------------------------------------------
        var type = String(that.flag)
        if(that.flag==1){
          let parames={
            account:this.$store.state.userinfo.accountName,
            type:type,
            orgId:this.$store.state.userinfo.org.id,
            perOrgConfigId:that.workTable[0].perOrgConfigId,
            bizConfigListStr:JSON.stringify(bizConfigListStr)
          }
        this.$confirm('您修改的绩效考核方案，只会影响下一期的绩效考核，不影响历史数据。您确定修改吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          roundButton: true
        }).then(() => {
          if(that.rowallGrade == 100){
            updatePerInfo(parames).then(res=>{
              if(res.status==200){
                that.$message.success('保存成功！')
                that.yuangongFlag=true;
                that.deptFlag=true;
              }
            })
          }else{
            that.$message.warning('请确保分数等于100')
          }
        }).catch(() => {
        })
        }else if(that.flag==2){
          let parames={
            account:this.$store.state.userinfo.accountName,
            type:type,
            orgId:this.$store.state.userinfo.org.id,
            perOrgConfigId:that.workTable[0].perOrgConfigId,
            bizConfigListStr:JSON.stringify(deptListStr)
          }
          this.$confirm('您修改的绩效考核方案，只会影响下一期的绩效考核，不影响历史数据。您确定修改吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          roundButton: true
          }).then(() => {
            if(that.deptallGrade == 100){
              updatePerInfo(parames).then(res=>{
                if(res.status==200){
                  that.$message.success('保存成功！')
                }
                that.yuangongFlag=true;
                that.deptFlag=true;
              })
            }else{
              that.$message.warning('请确保分数等于100')
            }
          }).catch(() => {
          })
        }
        // that.yuangongFlag=true;
        // that.deptFlag=true;
    },
    updateData(){//编辑
        let that = this;
        if(that.yuangongFlag==true){
            that.yuangongFlag=false;
        }
        if(that.deptFlag==true){
            that.deptFlag=false;
        }
    },
    handleChange_row1d5() {
      let that = this;
      that.row1.d6 =
        that.row1.d6.substr(0, that.row1.d6.lastIndexOf("*") + 1) +
        that.row1.d5;
      
    },
    handleChange_row9d2() {
      let that = this;
      that.row9.d3 =
        that.row9.d3.substr(0, that.row9.d3.lastIndexOf("*") + 1) +
        that.row9.d2;
    },
    handleChange_row10d2() {
      let that = this;
      that.row10.d3 =
        that.row10.d3.substr(0, that.row10.d3.lastIndexOf("=") + 1) +
        that.row10.d2 +
        that.row10.d3.substr(that.row10.d3.lastIndexOf("-"));
    },
    //计算分数部门绩效
    departmentChange_deptRow1d2() {
      let that = this;
      that.deptRow1.d3 =
        that.deptRow1.d3.substr(0, that.deptRow1.d3.lastIndexOf("*") + 1) +
        that.deptRow1.d2;
    },
    departmentChange_deptRow9d2() {
      let that = this;
      that.deptRow9.d3 =
        that.deptRow9.d3.substr(0, that.deptRow9.d3.lastIndexOf("*") + 1) +
        that.deptRow9.d2;
    },
    departmentChange_deptRow10d2() {
      let that = this;
      that.deptRow10.d3 =
        that.deptRow10.d3.substr(0, that.deptRow10.d3.lastIndexOf("=") + 1) +
        that.deptRow10.d2 +
        that.deptRow10.d3.substr(that.deptRow10.d3.lastIndexOf("-"));
    },
    //第一行数据处理
    handleRow1(data) {
      let that = this;
      let roleList = JSON.parse(data.ruleSet);
      for (let m in roleList) {
        let key = roleList[m].roleId;
        if (key == 142) {
          that.row1.d4 = roleList[m].time;
        } else if (key == 144) {
          that.row1.d1 = roleList[m].time;
        } else if (key == 145) {
          that.row1.d3 = roleList[m].time;
        } else if (key == 160) {
          that.row1.d2 = roleList[m].time;
        }
      }
      that.row1.d5 = data.totalPoints;
      that.row1.d6 = JSON.parse(data.evaluateDesc).data[0].replace(
        "$s",
        that.row1.d5
      );
    },
    handleRow2(data) {
      let that = this;
      that.row2.d1 = JSON.parse(data.ruleDesc).data[0];
      that.row2.d2 = data.totalPoints;
      that.row2.d3 = JSON.parse(data.arithmeticConfig).$e1;
      that.row2.d4 = JSON.parse(data.arithmeticConfig).$e2;
    },
    handleRow3(data) {
      let that = this;
      that.row3.d1 = JSON.parse(data.ruleDesc).data[0];
      that.row3.d2 = data.totalPoints;
      that.row3.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleRow4(data) {
      let that = this;
      that.row4.d1 = data.ruleSet;
      that.row4.d2 = data.totalPoints;
      that.row4.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleRow5(data) {
      let that = this;
      that.row5.d1 = data.ruleSet;
      that.row5.d2 = data.totalPoints;
      that.row5.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleRow6(data) {
      let that = this;
      that.row6.d1 = JSON.parse(data.ruleDesc).data[0];
      that.row6.d2 = data.totalPoints;
      that.row6.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleRow7(data) {
      let that = this;
      that.row7.d1 = data.ruleSet;
      that.row7.d2 = data.totalPoints;
      that.row7.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleRow8(data) {
      let that = this;
      that.row8.d1 = data.ruleSet;
      that.row8.d2 = data.totalPoints;
      that.row8.d3 = JSON.parse(data.arithmeticConfig).$e1;
      that.row8.d4 = JSON.parse(data.arithmeticConfig).$e2;
    },
    handleRow9(data) {
      let that = this;
      that.row9.d1 = data.ruleSet;
      that.row9.d2 = data.totalPoints;
      that.row9.d3 = JSON.parse(data.evaluateDesc).data[0].replace(
        "$s",
        that.row9.d2
      );
    },
    handleRow10(data) {
      let that = this;
      that.row10.d1 = JSON.parse(data.ruleDesc).data[0];
      that.row10.d2 = data.totalPoints;
      that.row10.d3 = JSON.parse(data.evaluateDesc)
        .data.join()
        .replace("$s", that.row10.d2);
    },
    handleDeptRow1(data) {
      let that = this;
      //let roleList = JSON.parse(data.ruleSet);
      that.deptRow1.d1 = JSON.parse(data.ruleDesc).data[0];
      that.deptRow1.d2 = data.totalPoints;
      that.deptRow1.d3 = JSON.parse(data.evaluateDesc).data[0].replace(
        "$s",
        that.deptRow1.d2
      );
    },
    handleDeptRow2(data) {
      let that = this;
      that.deptRow2.d1 = JSON.parse(data.ruleDesc).data[0];
      that.deptRow2.d2 = data.totalPoints;
      that.deptRow2.d3 = JSON.parse(data.arithmeticConfig).$e1;
      that.deptRow2.d4 = JSON.parse(data.arithmeticConfig).$e2;
    },
    handleDeptRow3(data) {
      let that = this;
      that.deptRow3.d1 = JSON.parse(data.ruleDesc).data[0];
      that.deptRow3.d2 = data.totalPoints;
      that.deptRow3.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleDeptRow4(data) {
      let that = this;
      that.deptRow4.d1 = data.ruleSet;
      that.deptRow4.d2 = data.totalPoints;
      that.deptRow4.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleDeptRow5(data) {
      let that = this;
      that.deptRow5.d1 = data.ruleSet;
      that.deptRow5.d2 = data.totalPoints;
      that.deptRow5.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleDeptRow6(data) {
      let that = this;
      that.deptRow6.d1 = JSON.parse(data.ruleDesc).data[0];
      that.deptRow6.d2 = data.totalPoints;
      that.deptRow6.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleDeptRow7(data) {
      let that = this;
      that.deptRow7.d1 = data.ruleSet;
      that.deptRow7.d2 = data.totalPoints;
      that.deptRow7.d3 = JSON.parse(data.arithmeticConfig).$e1;
    },
    handleDeptRow8(data) {
      let that = this;
      that.deptRow8.d1 = data.ruleSet;
      that.deptRow8.d2 = data.totalPoints;
      that.deptRow8.d3 = JSON.parse(data.arithmeticConfig).$e1;
      that.deptRow8.d4 = JSON.parse(data.arithmeticConfig).$e2;
    },
    handleDeptRow9(data) {
      let that = this;
      that.deptRow9.d1 = data.ruleSet;
      that.deptRow9.d2 = data.totalPoints;
      that.deptRow9.d3 = JSON.parse(data.evaluateDesc).data[0].replace(
        "$s",
        that.deptRow9.d2
      );
    },
    handleDeptRow10(data) {
      let that = this;
      that.deptRow10.d1 = JSON.parse(data.ruleDesc).data[0];
      that.deptRow10.d2 = data.totalPoints;
      that.deptRow10.d3 = JSON.parse(data.evaluateDesc)
        .data.join()
        .replace("$s", that.deptRow10.d2);
    }
  }
};
</script>
<style lang="scss" scoped>
.more-btns {
  margin-top: 20px;
}
.performance_main_bottom {
    text-align: center;
    .line {
        margin-top: 20px;
    }
    .performance_main_bottom_table {
        border-collapse: collapse;
            td {
            border-bottom: 1px solid #e6e6e6;
            padding: 15px 0px 15px 0px;
                label{
                    //display: block;
                    //float: left;
                    // margin-left: 0px;
                    // margin-top: 10px;
                }
            }
    }
}
.performance_main_bottom_title {
  width: 100%;
}
</style>
<style>
.is-active {
  color: #409eff;
}
</style>